package com.agou.core.ss;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;

/**
 * 此类存放异常及其调用栈
 */
public class SSThrowable implements java.io.Serializable {
	public static final long serialVersionUID = 1;

	private Throwable thrown = null;// 包含了其线程创建时线程执行堆栈的快照。
	private String stack = null;// thrown的调用栈

	/**
	 * 构造函数
	 * 
	 */
	public SSThrowable(Throwable e) {
		this.thrown = e;
		ByteArrayOutputStream osCallStack = new ByteArrayOutputStream();
		PrintWriter pw = new PrintWriter(osCallStack);
		e.printStackTrace(pw);
		pw.flush();
		pw.close();
		stack = osCallStack.toString();
		return;
	}

	/**
	 * 取得异常的调用栈
	 */
	public String getStack() {
		return this.stack;
	}

	/**
	 * 取得异常对象
	 * 
	 */
	public Throwable getThrown() {
		return thrown;
	}
}